﻿using System.Collections.Generic;
using System.Linq;
using Tateeda.ClinicalStudy.Base.Data.DBModel;
using Tateeda.ClinicalStudy.Base.Modules.Common.Extenstions;
using Tateeda.ClinicalStudy.Base.Modules.Models.Utility;

namespace Tateeda.ClinicalStudy.Base.Modules.Common.Extentions {

    public static class UtilityExtension {

        public static CTGovSubmissionModel ToCTGovSubmissionModel(this CTGovSubmission item) {
            var to = new CTGovSubmissionModel();
            To(item, ref to);
            return to;
        }

        public static ICollection<CTGovSubmissionModel> ToCTGovSubmissionModelList(this ICollection<CTGovSubmission> list) {
            return list.Select(s => s.ToCTGovSubmissionModel()).ToList();
        }

        public static CTGovSubmission ToCTGovSubmission(this CTGovSubmissionModel model) {
            var to = new CTGovSubmission();
            To(model, ref to);
            return to;
        }

        public static ICollection<CTGovSubmission> ToCTGovSubmissionList(this ICollection<CTGovSubmissionModel> list) {
            return list.Select(s => s.ToCTGovSubmission()).ToList();
        }

        #region - Base function for Objects conversions -

        private static void To<TF, T>(TF from, ref T to) {
            ExtensionBase.To(from, ref to);
        }

        #endregion - Base function for Objects conversions -
    }
}